﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
    <title>Samek: Samek.cpp Source File</title>
    <link href="/Content/Help.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/tabs.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header">
        <img id="logo" alt="StateForge" src="/Content/Images/StateForgeLogo.png" />
        <div id="title">
            <h1>
                Examples using state machines generated by StateBuilderCpp
            </h1>
            <h3>
                Samek: Samek.cpp Source File
            </h3>
        </div>
        <div id="menucontainer">
            <ul id="menu">
                <li><a href="/">Home</a></li>
                <li><a href="/Home/Download">Downloads</a></li>
                <li><a href="/Help/state-machine-tools.aspx">Help</a></li>
                <li><a href="/Home/Faq">F.A.Q</a></li>
                <li><a href="/Home/About">Contact us</a></li>
            </ul>
        </div>
    </div>
<!-- Generated by Doxygen 1.7.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Samek.cpp</div>  </div>
</div>
<div class="contents">
<a href="_samek_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;ObserverStd.h&gt;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="_samek_8h.html">Samek.h</a>&quot;</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="keyword">using namespace </span>std;
<a name="l00011"></a>00011 
<a name="l00012"></a><a class="code" href="_samek_8cpp.html#a7a21204459b1fa26f83e9fd9bff74679">00012</a> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="_samek_8cpp.html#a7a21204459b1fa26f83e9fd9bff74679">RTX_COUNT</a> = 5;
<a name="l00013"></a>00013 
<a name="l00014"></a><a class="code" href="class_samek.html#a1e9a752c1de642c13a4f0f3f7842b194">00014</a> <a class="code" href="class_samek.html#a1e9a752c1de642c13a4f0f3f7842b194">Samek::Samek</a>()
<a name="l00015"></a>00015 : foo(0)
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017     <a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a> = <span class="keyword">new</span> SamekContext(*<span class="keyword">this</span>);
<a name="l00018"></a>00018     <a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a>-&gt;SetObserver(fsm::ObserverStd::GetInstance());
<a name="l00019"></a>00019     <a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a>-&gt;EnterInitialState();
<a name="l00020"></a>00020 }
<a name="l00021"></a>00021 
<a name="l00022"></a><a class="code" href="class_samek.html#a1bb9562d379e2799354cebb0181a06a9">00022</a> <a class="code" href="class_samek.html#a1bb9562d379e2799354cebb0181a06a9">Samek::~Samek</a>()
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024     <span class="keyword">delete</span> <a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a>;
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 }
<a name="l00027"></a><a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">00027</a> SamekContext&amp; <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">Samek::GetContext</a>()
<a name="l00028"></a>00028 {
<a name="l00029"></a>00029     <span class="keywordflow">if</span>(<a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a> != NULL){
<a name="l00030"></a>00030         <span class="keywordflow">return</span> *<a class="code" href="class_samek.html#a3db5ee5d6fa767406bb43cc29836e80d">m_pContext</a>;
<a name="l00031"></a>00031     } <span class="keywordflow">else</span> {
<a name="l00032"></a>00032         <span class="keywordflow">throw</span> runtime_error(<span class="stringliteral">&quot;context is not set&quot;</span>);
<a name="l00033"></a>00033     }
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="class_samek.html#a4976d508bc75e8a62bfaa7dfa61db7a9">00036</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#a4976d508bc75e8a62bfaa7dfa61db7a9">Samek::a</a>()
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().a();
<a name="l00039"></a>00039 }
<a name="l00040"></a>00040 
<a name="l00041"></a><a class="code" href="class_samek.html#a0281e066a9875b2e295601e9341c94f0">00041</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#a0281e066a9875b2e295601e9341c94f0">Samek::b</a>()
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().b();
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="class_samek.html#aa96efee256f3c102073d2d876397c4ac">00046</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#aa96efee256f3c102073d2d876397c4ac">Samek::c</a>()
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().c();
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050 
<a name="l00051"></a><a class="code" href="class_samek.html#a0eaf3328023bb235083294a078fb67fc">00051</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#a0eaf3328023bb235083294a078fb67fc">Samek::d</a>()
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().d();
<a name="l00054"></a>00054 }
<a name="l00055"></a><a class="code" href="class_samek.html#aa2579321dfe89e5767505852a34ed4e3">00055</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#aa2579321dfe89e5767505852a34ed4e3">Samek::e</a>()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().e();
<a name="l00058"></a>00058 }
<a name="l00059"></a><a class="code" href="class_samek.html#ab502df52aa455ec16c5200428e152269">00059</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#ab502df52aa455ec16c5200428e152269">Samek::f</a>()
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().f();
<a name="l00062"></a>00062 }
<a name="l00063"></a><a class="code" href="class_samek.html#ac1d0fc5b583a1826d94ffeb7cfbedfd3">00063</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#ac1d0fc5b583a1826d94ffeb7cfbedfd3">Samek::g</a>()
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().g();
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="class_samek.html#afe09e083a69e8e19d0003eb125ec8aba">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#afe09e083a69e8e19d0003eb125ec8aba">Samek::h</a>()
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070     <a class="code" href="class_samek.html#a9d44040f845825a7396f267c2ea17a64">GetContext</a>().h();
<a name="l00071"></a>00071 }
<a name="l00072"></a><a class="code" href="class_samek.html#ae386dc1cabf05fd07879de9ecb2ecd88">00072</a> <span class="keywordtype">void</span> <a class="code" href="class_samek.html#ae386dc1cabf05fd07879de9ecb2ecd88">Samek::Print</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;message)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074     cout &lt;&lt; message;
<a name="l00075"></a>00075 }
</pre></div></div>
</div>
﻿<div id="footer">
    <hr />
    <p>
        Copyright &copy; 2011 StateForge.</p>
    <hr />
</div>
</body> </html> 
